package cn.cnsuh.q344_reverseString;

import java.util.Arrays;

/**
 * created by mzk on 2020/07/21
 */
public class Main {

    public static void main(String[] args) {
        char[] arr = {'h','e','l','l','o'};

        fun1(arr);
        fun1(arr);
        fun2(arr);
        fun2(arr);
    }

    static void fun1(char[] s){
        for(int i = 0 ; i < s.length/2; i++){
            char tmp = s[i];
            s[i] = s[s.length-1-i];
            s[s.length-1-i] = tmp;
        }
        System.out.println(Arrays.toString(s));
    }

    static void fun2(char[] s){
        char[] newS = new char[s.length];
        for(int i = 0; i < s.length ; i++){
            newS[i] = s[i];
        }

        for(int i = 0 ; i < s.length ; i++){
            s[i] = newS[s.length-1-i];
        }
        System.out.println(Arrays.toString(s));
    }
}
